import qs from "qs"
import request from "utils/request"
import {AuthForm} from "views/login";

// 获取验证码
export const reqCode = () => request({
    url: '/auth/verifiCode/code',
    method: 'GET',
})

//登录
export const reqLogin = (data: AuthForm) => request(
    {
        url: '/auth/oauth/token',
        data: qs.stringify({
            grant_type: "password",
            client_id: "admin",
            client_secret: "123456",
            ...data
        }),
        headers: {
            'Content-Type': 'application/x-www-form-urlencoded'
        }
    }
)

// 退出登录
export const reqLogout = () => request({
        url: '/auth/oauth/logout',
        method: 'GET'
    }
)

// 请求用户信息
export function reqInfo() {
    return request({
        url: '/system/admin/user/info',
        method: 'post'
    })
}
